<?php
require ('Category.class.php');
require ('Site.class.php');
require ('User.class.php');
class HTMLManager {

    private static $days = array('Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom');

    public static function get_head_content() {
        ?>

        <meta charset="utf8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <link rel="shortcut icon" href="http://www.salesianichioggia.it/img/favicon.ico">
        <link type="text/css" rel="stylesheet" href="http://www.salesianichioggia.it/bootstrap/css/bootstrap.css" />
        <link type="text/css" rel="stylesheet" href="http://www.salesianichioggia.it/bootstrap/css/bootstrap-responsive.css" />
        <link type="text/css" rel="stylesheet" href="http://www.salesianichioggia.it/css/base.css" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){	
                var visible = false;
                $("#show-menu-collapse").click(function(){
                    $("#menu").slideToggle('slow');
                });
                					
                $("ul#social > li > a > img").popover({
                    animation : true,
                    placement : 'bottom',
                    trigger : 'hover',
                    content : 'Seguici!'
                });
            });
        </script>
        <!--[if lt IE 9]>
                <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-35690287-1']);
            _gaq.push(['_trackPageview']);

            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();

        </script>

        <?php
    }

    public static function get_header() {
        ?>
        <header>
            <div class="container" id="header-content">
                <div class="row">
                    <div class="span3 offset1"><a href="http://www.salesianichioggia.it"><img src="http://www.salesianichioggia.it/img/logo.png" alt="Logo OSC" id="logo"/></a></div>
                    <div class="span8" id="header-title-info">
                        <h1>Oratorio Salesiano Chioggia</h1>
                        <div class="row">
                            <div class="span5">
                                <ul class="unstyled" id="address">
                                    <li><i class="icon-map-marker icon-black"></i> Calle don Bosco 361, 30015 Chioggia (VE)</li>
                                    <li><i class="icon-comment icon-black"></i> Tel + Fax: 041 400 365</li>
                                </ul>
                            </div>
                            <div class="span3">
                                <ul id="social" class="unstyled">
                                    <li><a href="https://www.facebook.com/pages/salesianichioggiait/143371202433312?fref=ts"><img src="http://www.salesianichioggia.it/img/social-facebook.png" alt="Facebook" title="La Pagina Facebook" data-content="Clicca Mi Piace alla pagina ufficiale dell'Oratorio Salesiano di Chioggia e rimani aggiornato su tutti gli eventi!"/></a></li>
                                    <li><a href="https://twitter.com/salesianichio"><img src="http://www.salesianichioggia.it/img/social-twitter.png" alt="Twitter"  title="La Pagina Twitter" data-content="Seguici su Twitter e rimani sempre aggiornarnato sui nostri eventi!"/></a></li>
                                    <li><a href="https://plus.google.com/b/115040261777579728680/115040261777579728680/posts"><img src="http://www.salesianichioggia.it/img/social-gplus.png" alt="Google+"  title="La Pagina Google+" data-content="Seguici su Google+ e rimani sempre aggiornarnato su tutti i nostri eventi!"/></a></li>
                                    <li><a href="http://www.youtube.com/user/SalesianiChioggia"><img src="http://www.salesianichioggia.it/img/social-youtube.png" alt="Youtube"  title="Il Canale Youtube" data-content="Iscriviti al nostro canale e guarda tutti i nostri video. Divertimento assicurato!"/></a></li>
                                    <li><a href="http://www.donboscoland.it"><img src="http://www.salesianichioggia.it/img/social-dbland.png" alt="MGS"  title="Il sito del MGS" data-content="Notizie e eventi del Movimento Giovanile Salesiano Triveneto!"/></a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <nav>
                <div class="container">
                    <div class="row">
                        <div id="menu-header-collapse" class="span12">
                            <ul>
                                <li>
                                    <a class="brand" href="#">salesianichioggia.it</a>
                                </li>
                                <li>
                                    <button class="btn btn-large" id="show-menu-collapse">
                                        <i class="icon-chevron-down icon-black"></i>
                                    </button>
                                </li>
                            </ul>
                        </div>
                        <div class="menu-collapse span12" id="menu">
                            <ul>
                                <li>
                                    <a href="#">Articoli</a>
                                    <ul class="submenu">
                                        <li><a href="http://www.salesianichioggia.it/articoli/archivio">Archivio</a></li>
                                        <li><a href="">Categorie</a>
                                            <ul>
                                                <?php
                                                $am = new ArticleManager();
                                                $categories = $am->get_categories();

                                                foreach ($categories as $category) {
                                                    ?>
                                                    <li><a href="http://www.salesianichioggia.it/articoli/archivio/categorie/<?= $category->id ?>"><?= $category->description ?></a></li>
                                                <?php } ?>
                                            </ul>
                                        </li>
                                    </ul>
                                </li>
                                <li>
                                    <a href="">Fotografie</a>
                                    <ul class="submenu">
                                        <li><a href="http://www.salesianichioggia.it/gallerie/">Archivio</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href="">Cinema - Teatro</a>
                                    <ul class="submenu">
                                        <li><a href="http://www.salesianichioggia.it/cinema">Programmazione Cinema</a></li>
                                        <li><a href="http://www.salesianichioggia.it/cinema/lineeguida">Linee Guida Cinema</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href="http://www.salesianichioggia.it/contattaci">Contattaci</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </nav>
        </header>
        <?php
    }

    public static function get_footer() {
        ?>
        <footer>
            <div class="container">
                <div class="row">
                    <div class="span12">
                        <h5>Istituto Salesiano San Marco - Oratorio Salesiano Chioggia - P. Iva: 02173980273 - C.F.: 82000110278</h5>
                    </div>
                </div>
            </div>
        </footer>
        <?php
    }

    public static function get_page_navigation($num_pages, $current_page, $url) {
        ?>
        <div class="pagination pagination-centered">
            <ul>
                <li <?= ($current_page == 1) ? 'class="disabled"' : '' ?>><a href="<?= ($current_page > 1) ? 'http://www.salesianichioggia.it/' . $url . '/pagina/' . ($current_page - 1) : "#" ?>">Precedente</a></li>
                <?php for ($i = 1; $i <= $num_pages; $i++) { ?>
                    <li <?= ($i == $current_page) ? 'class="active"' : '' ?>> <a href="http://www.salesianichioggia.it/<?= $url . '/pagina/' . $i ?>" ><?= $i ?> </a></li>
                    <?php
                }
                ?>
                <li <?= ($current_page == $num_pages) ? 'class="disabled"' : '' ?>><a href="<?= ($current_page < $num_pages) ? 'http://www.salesianichioggia.it/' . $url . '/pagina/' . ($current_page + 1) : "#" ?>" >Successivo</a></li>
            </ul>
        </div>
        <?php
    }

    private static function get_day_number($str_date) {
        $date = new DateTime($str_date);
        return $date->format('d');
    }

    private static function get_day_title($str_date) {
        return self::get_day_number($str_date) . ', ' . self::get_day_name($str_date);
    }

    public static function get_community_week($days_array) {
        ?>
        <div class="span8" id="calendar">
            <h1>Settimana della Comunità</h1>

            <?php
            $i = 0;
            foreach ($days_array as $date => $events_array) {
                if ($i % 4 == 0) {
                    ?>
                    <div class="row group-day">
                        <?php
                    }
                    $i++;
                    ?>

                    <div class="span2 day <?= ($i == 1) ? 'today' : '' ?>">
                        <h2><?= self::get_day_title($date) ?></h2>
                        <ul class="unstyled">
                            <?php foreach ($events_array as $event) { ?>
                                <li><div class="label label-info event <?= $event->get_style() ?>" data-content="<?= $event->description ?>" data-original-title="<?= $event->title ?>"><?= (!$event->all_day) ? $event->get_start_end_time() . ' - ' : '' ?><?= $event->title ?></div></li>
                            <?php } ?>
                        </ul>
                    </div>

                    <?php if ($i % 4 == 0) { ?>
                    </div>
                    <?php
                }
            }
            ?>
        </div>
        <?php
    }

    public static function get_cinema($cinema) {
        ?>
        <div class="span3" id="cinema">
            <h1>Cinema</h1>

            <div id="cinema-carousel" class="carousel slide">
                <div class="carousel-inner"> 
                    <?php
                    foreach ($cinema as $film) {
                        ?>
                        <div class="item">
                            <a href="http://www.salesianichioggia.it/cinema#<?= $film->get_div_id() ?>"><img src="<?= ($film->poster) ? 'http://www.salesianichioggia.it/images/' . $film->poster : 'http://placehold.it/270x310' ?>" width="270" height="310" /></a>
                        </div>
                        <?php
                    }
                    ?>
                </div>
            </div>
        </div>
        <?php
    }

    public static function get_hotnews($hotnews_array) {
        ?>
        <div class="span9" id="hotnews">
            <div id="hotnews-carousel" class="carousel slide">
                <div class="carousel-inner">
                    <?php
                    $first = true;
                    foreach ($hotnews_array as $hn) {
                        ?>
                        <div class="item <?= ($first) ? 'active' : '' ?>">
                            <img src="<?= ($hn->image) ? 'http://www.salesianichioggia.it/images/' . $hn->image : 'http://placehold.it/870x350' ?>" />
                            <div class="carousel-caption">
                                <h4><?= $hn->title ?></h4>
                                <p><?= $hn->abstract ?></p>
                            </div>
                        </div>
                        <?php
                        $first = false;
                    }
                    ?>
                </div>
                <?php
                if (count($hotnews_array) > 1) {
                    ?>
                    <a class="left carousel-control" href="#hotnews-carousel" data-slide="prev">&lsaquo;</a>
                    <a class="right carousel-control" href="#hotnews-carousel" data-slide="next">&rsaquo;</a>
                <?php } ?>
            </div>
        </div>
        <?php
    }

    public static function get_last_articles($articles_array) {
        ?>
        <div class="span4" id="news">
            <h1>News</h1>
            <?php
            foreach ($articles_array as $article) {
                ?>
                <div class="row">
                    <div class="span1">
                        <a href="http://www.salesianichioggia.it/<?= $article->get_seo_link() ?>"><span class="img-wrap"><img src="<?= ($article->image) ? 'http://www.salesianichioggia.it/images/' . $article->image : 'http://placehold.it/70x70' ?>" alt="" class="img-circle" width="70" height="70"/></span></a>
                    </div>
                    <div class="span3">
                        <a href="http://www.salesianichioggia.it/<?= $article->get_seo_link() ?>"><h5><?= $article->title ?></h5></a>
                        <p><?= $article->abstract ?></p>
                        <a href="http://www.salesianichioggia.it/<?= $article->get_seo_link() ?>">Leggi</a>
                    </div>
                </div>
                <hr />
                <?php
            }
            ?>
        </div>
        <?php
    }

    public static function get_sidebar_categories_menu($current_category) {
        ?>
        <ul class="nav nav-tabs nav-stacked">
            <?php
            $am = new ArticleManager();
            $categories = $am->get_categories();

            foreach ($categories as $category) {
                ?>
                <li <?= ($current_category == $category->id) ? 'class="active"' : '' ?>><a href="http://www.salesianichioggia.it/articoli/archivio/categorie/<?= $category->id ?>"><?= $category->description ?></a></li>
            <?php } ?>
        </ul>
        <?php
    }

    private static function get_day_name($str_date) {
        $date = new DateTime($str_date);
        return self::$days [$date->format('N') - 1];
    }
    
     public static function get_dashboard_navigation($user) { ?>
      
            <div class="navbar navbar-fixed-top">
                <div class="navbar-inner">
                    <div class="container-fluid">
                        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </a>
                        <a class="brand" href="#">salesianichioggia.it</a>
                        <div class="btn-group pull-right">
                            <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="icon-user"></i> <?= $user->get_name() ?>
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Profilo</a></li>
                                <li class="divider"></li>
                                <li><a href="http://www.salesianichioggia.it/dashboard/logout.php">Log Out</a></li>
                            </ul>
                        </div>
                        <div class="nav-collapse collapse" style="height: 0px; ">
                            <ul class="nav">
                                <li><a href="http://www.salesianichioggia.it/dashboard/index.php">Home</a></li>
                                <li><a href="#about">Help</a></li>
                                <li><a href="mailto:webmaster@salesianichioggia.it">Contatta il Web Master</a></li>
                            </ul>
                        </div><!--/.nav-collapse -->
                    </div>
                </div>
            </div>
        </nav>
    <?php
    }
    
    public static function get_dashboard_activities($user) { ?>
        <div class="span3">
                    <div class="well sidebar-nav">
                        <ul class="nav nav-list">
                            <?php 
                                if (in_array(1, $user->permissions) || in_array(2, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-file"></i>Gestione Articoli</li>
                                    <li><a href="#">Scrivi Articolo <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Modifica Articolo <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Gestisci Categorie <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(4, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-calendar"></i>Gestione Settimana</li>
                                    <li><a href="http://www.salesianichioggia.it/dashboard/event.php?action=new">Aggiungi Evento</a></li>
                                    <li><a href="http://www.salesianichioggia.it/dashboard/event.php?action=list">Modifica Evento</a></li>
                                    <li><a href="#">Visualizza Mese <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(6, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-fire"></i>Gestione Hotnews</li>
                                    <li><a href="#">Aggiungi Hotnews <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Modifica Ordine <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(9, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-camera"></i>Gestione Gallerie</li>
                                    <li><a href="http://www.salesianichioggia.it/dashboard/gallery.php?action=new">Aggiungi Galleria</a></li>
                                    <li><a href="http://www.salesianichioggia.it/dashboard/gallery.php?action=list">Modifica Galleria</a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(3, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-film"></i>Gestione Cinema</li>
                                    <li><a href="#">Aggiungi Proiezione <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Modifica Proiezione <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(5, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-folder-open"></i>Gestione Materiale</li>
                                    <li><a href="#">Aggiungi Materiale <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Modifica Materiale <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions) || in_array(8, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-thumbs-up"></i>Gestione Gruppi</li>
                                    <li><a href="#">Modifica Pagina Gruppo <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                if (in_array(1, $user->permissions)) { ?>
                                    <li class="nav-header"><i class="icon-user"></i>Gestione Utenti</li>
                                    <li><a href="#">Aggiungi Utente <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Modifica Utente <span class="label label-important">Coming Soon</span></a></li>
                                    <li><a href="#">Visualizza Utenti <span class="label label-important">Coming Soon</span></a></li>
                            <?php        
                                }
                                
                                
                            ?>
                        </ul>
                    </div>
                </div>
    <?php
    }

}
?>
